<?php
include_once("../inc/connection.php");
include_once("../inc/constants.inc.php");
session_start();

if(!isset($_SESSION['login']) || empty($_SESSION['login']) || !isset($_SESSION['email']) || empty($_SESSION['email']) || !isset($_SESSION['user_role']))
	{
		header("Location: login.php?error=invalid-access");
		exit(0);
	}
elseif($_SESSION['user_role']==2)
	{
		header("Location: test.php?error=invalid-access");
		exit(0);
	}
	
	
if(isset($_GET['del_id']))
{
$del_id = $_GET['del_id'];
 mysql_query("DELETE FROM question_type WHERE QTypeID='$del_id'");
 $url="../question-type.php";             // to reload the server
 header("Refresh:0;URL=$url");
 exit(0);
}

if(isset($_POST['add-type']))
{
$type = $_POST['QType'];
 mysql_query("INSERT INTO question_type (QType)
         VALUE('$type')");
 $url="../question-type.php";             // to reload the server
 header("Refresh:0;URL=$url");
 exit(0);
}

if(isset($_POST['update-type']))
{
$type_id = $_POST['QTypeID'];
$type = $_POST['QType'];
 mysql_query("UPDATE question_type SET QType='$type' WHERE QTypeID='$type_id'");
 $url="../question-type.php";             // to reload the server
 header("Refresh:0;URL=$url");
 exit(0);
}




?>